import React, { useState } from 'react';
import { Form, Descriptions, Modal } from 'antd';
import { FormValueType } from '../data.d';
import '../index.less'


export interface DetailFormProps {
  onCancel: () => void;
  updateModalVisible: boolean;
  values: FormValueType;

}

const UpdateForm: React.FC<DetailFormProps> = (props) => {
  const [formVals] = useState<FormValueType>(props.values);

  const { updateModalVisible, onCancel, alarmSource,alarmLevel } = props;

  return (
    <Modal
      width={640}
      destroyOnClose
      title="报警记录详情"
      visible={updateModalVisible}
      footer={null}
      onCancel={() => onCancel()}
    >
      <Descriptions column={1} >
        <Descriptions.Item label="报警时间">{formVals.alarmTime}</Descriptions.Item>
        <Descriptions.Item label="报警设备">{formVals.deviceName}</Descriptions.Item>
        <Descriptions.Item label="报警规则：">{formVals.alarmName||'--'}</Descriptions.Item>
    
        <Descriptions.Item label="报警数值">{formVals.alarmValue}</Descriptions.Item>
        <Descriptions.Item label="报警变量">{formVals.browseName}</Descriptions.Item>
        <Descriptions.Item label="报警级别">{alarmLevel[formVals.alarmLevel]}</Descriptions.Item>
        <Descriptions.Item label="信息来源">{alarmSource[formVals.defectSource]}</Descriptions.Item>
        <Descriptions.Item label="处置状态">{formVals.state == 0 ? "未处置" : "已处置"}</Descriptions.Item>
        {/* <Descriptions.Item label="报警处置信息">{formVals.alarmAnswer}</Descriptions.Item> */}
        <Descriptions.Item label="处置建议">{formVals.handleOpinions}</Descriptions.Item>
        <Descriptions.Item label="报警处置信息">{formVals.alarmHandle}</Descriptions.Item>
        <Descriptions.Item label="处置人">{formVals.userName}</Descriptions.Item>
        <Descriptions.Item label="处置时间">{formVals.handleTime}</Descriptions.Item>
      </Descriptions>


    </Modal>
  );
};

export default UpdateForm;
